package com.ikun.starters.ip2region.auto;


import com.ikun.starters.ip2region.IP2regionService;
import com.ikun.starters.ip2region.impl.IP2regionServiceImpl;
import com.ikun.starters.ip2region.properties.IP2regionConfigurationProperties;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;

/**
 * @ClassName IP2regionAutoConfiguration
 * @Description:
 * @Author: ximeng
 * @CreateDate: 2024/1/20 16:32
 * @UpdateUser:
 * @UpdateDate: 2024/1/20 16:32
 * @UpdateRemark:
 * @Version: 1.0
 */
@SpringBootConfiguration
@ConditionalOnClass(IP2regionService.class)
//@EnableConfigurationProperties(IP2regionConfigurationProperties.class) //使用spring.factories 文件配置需要导入配置类 使用注解则不需要
public class IP2regionAutoConfiguration {
    /**
     * 自动装配
     *
     * @param ip2regionConfigurationProperties
     * @return
     */
    @Bean
    public IP2regionService IP2regionService(IP2regionConfigurationProperties ip2regionConfigurationProperties) {
        return new IP2regionServiceImpl(ip2regionConfigurationProperties.getParsePublicIpPath(), ip2regionConfigurationProperties.getDbPath());
    }
}
